package br.com.lambdacore.validator.impl;

import java.util.Collection;

public final class CollectionValidator extends ValidatorImpl<Collection<?>> {

	protected CollectionValidator(Collection<?> collection) {
		super(collection);
	}

	public boolean contains(Object object) {
		return this.getObject().contains(object);
	}

	public boolean empty() {
		return this.getObject().isEmpty();
	}

	public boolean hasNull() {
		Collection<?> collection = this.getObject();
		boolean nil = false;
		for (Object object : collection) {
			nil = is(object).nil() && nil;
		}
		return nil;
	}

	public boolean notContains(Object object) {
		return !this.getObject().contains(object);
	}

	public boolean notEmpty() {
		return !this.empty();
	}

	public boolean notNullOrEmpty() {
		return !this.nullOrEmpty();
	}

	public boolean nullOrEmpty() {
		return this.nil() || this.empty();
	}

	public boolean sizeEquals(Collection<?> collection) {
		return this.sizeEquals(collection.size());
	}

	public boolean sizeEquals(int size) {
		return this.getObject().size() == size;
	}

	public boolean sizeNotEquals(Collection<?> collection) {
		return this.sizeNotEquals(collection.size());
	}

	public boolean sizeNotEquals(int size) {
		return this.getObject().size() != size;
	}

	public static CollectionValidator is(Collection<?> collection) {
		return new CollectionValidator(collection);
	}
}
